package com.example.scala.chapter3

/**
 *
 * Description:
 *
 * Create by lucienoz on 2021/10/15.
 * Copyright © 2021 lucienoz. All rights reserved.
 */
object chapter06 {
  def main(args : Array[String]) : Unit = {
    val A : Boolean = true
    val B : Boolean = true

    //1. 普通if判断
    if (A){
      //A为true，执行语句
      println("A is "+ true)
    }else if (B){
      println("B is "+true)
    }else{
      //A为true，执行语句
      println("A is "+ false)
    }

    //2. 当语句执行只有一句时可去掉{}
    if (A) println("A is "+ true) //执行语句和条件语句放在一行
    else if (B)
      println("B is "+true) //执行语句放在条件语句下一行
    else
      println("A is "+ false)

    //3. Scala没有三元表达式可通过if实现
    val i : Int = if (A) 1 else 0
    println(i)
  }

}
